<template>
  <div>
    <div class="hotsearch">
      <p>热门搜索:</p>
      <span
        v-for="(item, index) in hotSearchList"
        :key="index"
        @click="$emit('search', item.first)"
        >{{ item.first }}</span
      >
    </div>
    <div class="historysearch">
      <p>历史记录:</p>
      <span
        v-for="(item, index) in historyArr"
        :key="index"
        @click="$emit('search', item)"
        >{{ item }}</span
      >
    </div>
  </div>
</template>

<script>
export default {
  name: "HotSearch",
  props: {
    historyArr:Array
  },
  data() {
    return {
      hotSearchList: [],
    };
  },
  created() {
    this.$http.get("/search/hot").then((d) => {
      this.hotSearchList = d.data.result.hots;
    });
  },
  methods: {},
};
</script>

<style lang="less" scoped>
.hotsearch,.historysearch {
  padding: 15px;
  p {
    margin-bottom: 10px;
  }
  span {
    display: inline-block;
    height: 27px;
    text-align: center;
    border: 1px solid #e5e5e5;
    border-radius: 15px;
    padding: 0 10px;
    line-height: 27px;
    margin: 8px;
    background-color: #e5e5e5;
    color: #474747;
  }
}
</style>